using System;
using System.IO;
using System.Reflection;
using System.Xml;

namespace Google.Apps.Provisioning.Utilities
{
    /// <summary>
    /// Provides a convenience method for retrieving an Xml resource embedded in the currently executing
    /// assembly.
    /// </summary>
    public class EmbeddedResourceUtility
    {
        private EmbeddedResourceUtility() {;}

        public static XmlDocument GetXmlDocument( string resourceName )
        {
            XmlDocument doc = new XmlDocument();
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( resourceName );

            using ( StreamReader reader = new StreamReader( stream ) )
            {
                doc.Load( reader );
            }

            return doc;
        }
    }
}
